package com.crazymo.binderpool.exception;

import android.os.Build;
import android.support.annotation.RequiresApi;

/******************************************************************
 * @Copyright : (C), 2001-2021, ZHEJIANG DAHUA TECHNOLOGY CO.,LTD
 * @FileName : IllegalOperateException
 * @Author : 224967  Crazy.Mo
 * @Date : 2022/1/25 10:22
 * @Description :    
 * @History :
 * <author>  <time>  <version>   <desc>
 * 224967    修改时间    版本号       描述
 ******************************************************************/

public class MoException extends RuntimeException {
    private MoErrorEnum mErrorEnum;

    public MoException() {
        super(MoErrorEnum.UNSPECIFIED.getMessage());
    }

    public MoException(MoErrorEnum errorEnum) {
        mErrorEnum = errorEnum;
    }

    public MoException(String message, MoErrorEnum errorEnum) {
        super(errorEnum.getCode() + ":" + message);
        mErrorEnum = errorEnum;
    }

    public MoException(String message, Throwable cause, MoErrorEnum errorEnum) {
        super(errorEnum.getCode() + ":" + message, cause);
        mErrorEnum = errorEnum;
    }

    public MoException(Throwable cause, MoErrorEnum errorEnum) {
        super(errorEnum.getCode() + ":" + cause);
        mErrorEnum = errorEnum;
    }

    @RequiresApi(api = Build.VERSION_CODES.N)
    public MoException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, MoErrorEnum errorEnum) {
        super(errorEnum.getCode() + ":" + message, cause, enableSuppression, writableStackTrace);
    }
}